﻿/// <reference path="oogrid.js" />

$(document).ready(function () {
    var grid = new OOGrid("demoGrid");
    grid.Columns = BuildColumns();
    grid.Mode = OOGrid.Modes.Ajax;
    grid.AjaxUrl = "/demo/AjaxProducts";
    grid.OnPageIndexChanging(function(e) {
        //e.Args.Canceled = true;
    });
    grid.Initialize();

});


function BuildColumns() {
    var columns = new Array();
    columns.push(new Column().SetMember("ID").SetWidth(50));
    columns.push(new Column().SetMember("Name").SetWidth(150));
    columns.push(new Column().SetMember("Description").SetWidth("auto"));
    var created = new Column().SetMember("CreatedDate").SetWidth(150).SetMemberDataType(DataType.Date);
    created.HeaderHtml = "<b>Created <span style='color:blue'>Date</span></b>";
    created.CellFormaterFunction = function (date) {
        return (date.getMonth()+1) + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes();
    };
    columns.push(created);
    return columns;
}